package com.ys.servers.migrate.service.impl;

import com.ys.servers.common.util.CommonUtils;
import com.ys.servers.migrate.dao.VisitsOrgDao;
import com.ys.servers.migrate.service.MigrateTestService;
import io.vertx.core.json.JsonObject;

import java.util.List;

/**
 * Created by taotao on 2017/3/7.
 */
public class MigrateTestServiceImpl implements MigrateTestService {

    private VisitsOrgDao visitsOrgDao;

    public VisitsOrgDao getVisitsOrgDao() {
        return visitsOrgDao;
    }

    public MigrateTestService setVisitsOrgDao(VisitsOrgDao visitsOrgDao) {
        this.visitsOrgDao = visitsOrgDao;
        return this;
    }

    @Override
    public void getAllVisitOrgs() {
        getVisitsOrgDao().getAllVisitsOrg().setHandler(listAsyncResult -> {
            if(CommonUtils.validAsyncResult(listAsyncResult)){
                List<JsonObject> results=listAsyncResult.result();
                results.forEach(System.out::println);
            }else{
                System.out.println(listAsyncResult.cause());
            }
        });
    }
}
